import 'dart:async';

class EventBus {
  static StreamController<Object>? _controller;

  static StreamController<Object> _internalGetController() =>
      _controller ??= StreamController.broadcast();

  static void initialize() {
    // for initialize the stream controller, don't modify it.
    _internalGetController();
  }

  static Sink<T> getPublisher<T>() => _internalGetController() as Sink<T>;

  static Stream<T> getSubscriber<T>() =>
      _internalGetController().stream as Stream<T>;
}
